<template>
<div class="wrapper">
    <div v-if="web" class="header">
        <text class="header-text">上海卓顾信息科技有限公司</text>
        <div class="back-area" @click="back">
            <image class="back" :src="getUrl('image/back.png')"/>
        </div>
    </div>

    <text class="title">{{title}}</text>

    <div class="main">
        <slider class="slider" :infinite="false" @change="slider"  show-indicators=true>
            <div class="frame" v-for="(img,i) in imageList" :key="i">
                <image class="image" resize="cover" :src="img.src"/>
            </div>
            <indicator class="indicator"></indicator>
        </slider>
    </div>
    
</div>
</template>

<script>
const animation = weex.requireModule('animation');
export default {
    data () {
        return {
            web: false,
            current: 0,
            height: 0,
            title:'报税回执-国税',
            imageList:[
                { src: 'image/timg.jpg'},
                { src: 'image/timg.jpg'},
                { src: 'image/timg.jpg'}
            ]
        }
    },
    created(){
        let platform = weex.config.env.platform;
        let height = weex.config.env.deviceHeight;
        this.height = height-80-90;
        this.web = platform.toLowerCase()!=='web'?false:true;

        this.imageList.forEach(function(item){
            item.src = this.getUrl(item.src)
        },this)
    },
    methods:{
        getUrl(param){
            let bundleUrl = weex.config.bundleUrl; 
            bundleUrl = new String(bundleUrl); 
            let platform = weex.config.env.platform;
            var nativeBase;  
            var native;   

            nativeBase = bundleUrl.substring(0, bundleUrl.lastIndexOf('/') + 1)
            native = nativeBase.replace('components/','') + 'assets/' + param;
            
            return native;  
        },
        back(){
            var navigator = weex.requireModule('navigator')
            navigator.pop()
        },
        slider(e){
            switch(e.index){
                case 0:
                    this.title = '报税回执-国税';
                    break;
                case 1:
                    this.title = '报税回执-地税';
                    break;
                default:
                    this.title = '报税回执-个税';
            }
        },
    }
    
}
</script>

<style scoped>
.wrapper{
    background-color: #f5f5f5;
}
.header{
    height: 90px;
    width: 750px;
    background-color: #ffffff;
}
.header-text{
    height: 90px;
    line-height: 90px;
    text-align: center;
}
.back-area{
    width: 50px;
    height: 50px;
    position: absolute;
    left: 20px;
    top: 20px;
    align-items: center;
    justify-content: center;
}
.back{
    width: 30px;
    height: 30px;
}
.title{
    height: 70px;
    line-height: 70px;
    text-align: center;
    font-size: 32px;
    font-weight: bold;
}
.main{
    flex: 1;
    background-color: #DCDCDC;
}
.slider {
    margin-top: 25px;
    margin-left: 25px;
    width: 700px;
    height: 1000px;
  }
.frame {
  width: 700px;
  height: 1000px;
}
.image {
  width: 700px;
  height: 1000px;
}
.indicator {
    width: 700px;
    height: 100px;
    item-color: #008000;
    item-selected-color:#FF0000;
    item-size: 20px;
    position: absolute;
    top: 900px;
    left: 0;
  } 
</style>
